<?php

header('Content-Type:text/html;charset=utf-8');

@$a=$_POST['userName'];
@$b=$_POST['password'];


$PDO=new PDO('mysql:dbname=diancan;charset=UTF8;','root');

$sou=$PDO->prepare('select * from user where userName=:name');
$sou->execute(array('name'=>$a));
$cc=$sou->fetchAll(PDO::FETCH_NAMED);

if(empty($cc)){
	$sel=$PDO->prepare('insert into user(userName,password) values(:userName,:password)');
	$isok=$sel->execute(array('userName'=>$a,'password'=>$b));
	echo "恭喜你,注册成功,系统将在两秒内跳转!";
	header('Refresh:2;url=dl.php');
}else{
	echo "对不起,账号已存在.";
	header('Refresh:2;url=zc.php');
}

?>